package com.qianfeng.mapper.provider;

import com.qianfeng.mapper.pojo.TbUser;

/**
 * Created by Zhaohao on 2022/5/17 22:16
 *
 * @version 1.0
 * @auther Zhaohao
 * @since 1.0
 */
public class MyUserProvider {
    public String updateUser(TbUser user){
        StringBuffer stringBuffer = new StringBuffer("update tb_user set ");
        if(user.getEmail()!=null&&!"".equals(user.getEmail().trim())){
            stringBuffer.append("email= ").append("#{email}").append(" ,");
        }
        if(user.getUsername()!=null&&!"".equals(user.getUsername().trim())){
            stringBuffer.append("username= ").append("#{username}").append(" ,");
        }
        if(user.getPassword()!=null&&!"".equals(user.getPassword().trim())){
            stringBuffer.append("password= ").append("#{password}").append(" ,");
        }
        stringBuffer.deleteCharAt(stringBuffer.length()-1);
        stringBuffer.append("where id = ").append("#{id}");
        return stringBuffer.toString();
    }
}
